package service.impl;

import dao.UserDAO;
import dao.impl.UserDAOImpl;
import model.User;
import service.UserService;

import java.sql.Connection;
import java.util.List;

/**
 * @Description: TODO
 * @author: april
 * @date: 2021年12月04日 21:06
 */
public class UserServiceImpl extends BaseServiceImpl implements UserService {

    private static final UserDAO userDAO = new UserDAOImpl();

    @Override
    public User login(String username, String password) throws Exception {
        return userDAO.login(username, password);
    }

    @Override
    public User getLoginUser() throws Exception {
        Object obj = context.get(LOGIN_USER);
        if (obj != null) {
            return (User) obj;
        }
        return null;
    }

    @Override
    public List<User> getUserList() throws Exception {
        return userDAO.getUserList();
    }

    @Override
    public int addUser(User user) {
        return userDAO.addUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userDAO.updateUser(user);
    }

    @Override
    public int updateUserBalance(Connection con, User user, Integer flag, Double num) throws Exception {
        return userDAO.updateUserBalance(con, user, flag, num);
    }

    @Override
    public int updateUserBalance(User user, Integer flag, Double num) {
        return userDAO.updateUserBalance(user, flag, num);
    }


    @Override
    public User getUserByEmail(String email) {
        return userDAO.getUserByEmail(email);
    }


}
